package com.zslibrary.StateHandle;

import android.util.Log;

import com.zslibrary.Enum.StateDefine;
import com.zslibrary.Enum.StateEventDefine;
import com.zslibrary.Pipe.Pipe;
import com.zslibrary.Protocol.QueryGateStatus;
import com.zslibrary.Tools.ZSLog;

public class GateQueryState extends StateHandle {
    private Pipe mPipe;
    public GateQueryState(Pipe pipe){
        mPipe=pipe;
    }

    @Override
    public  @StateEventDefine.StateEvent int handle(){
        ZSLog.d("gate query state");
        return QueryGateStatus.queryGateStatus(mPipe);
    }

    @Override
    public @StateDefine.State int getNextHop(@StateEventDefine.StateEvent int event){
        if(event==StateEventDefine.EVT_RESET){
            return StateDefine.STATE_INIT;
        }
        else if(event== StateEventDefine.EVT_EXECUTE){
            return StateDefine.STATE_BUSY;
        }
        else if (event==StateEventDefine.EVT_DISCONNECT){
            return StateDefine.STATE_ERROR;
        }
        return StateDefine.STATE_IDLE;
    }
}
